/*
 * Copyright (c) 2021.版权所有高金磊
 */

package 领扣算法.AA中等题.森林中的兔子;

import java.util.HashMap;

public class Main {
    public int numRabbits(int[] answers) {
        for (int i = 0; i < answers.length; i++) {
            answers[i]++;
        }
        HashMap<Integer,Integer> data=new HashMap<>();
        for (int answer : answers) {
            data.put(answer, data.getOrDefault(answer, 0)+1);
        }
        int res=0;
        for (Integer integer : data.keySet()) {
            int middle=data.get(integer);
            while (middle>0){
                middle-=integer;
                res+=integer;
            }
        }
        return res;
    }
    public static void main(String arg[]){//main--来自高金磊
    
        new Main().numRabbits(new int[]{1,0,1,0,0});
    }
}
